Data flow graphs comprise a plurality of nodes that define how a query is to be executed. For a given data flow graph and its nodes, rules implemented by optimizers can be used to decided whether an optimization can be applied on a node or a sequence of nodes (i.e., whether the data flow graph can be modified in order to provide better performance). With conventional optimizers, heavy weighted rules and complex detection patterns must be adopted in order to optimize a data flow graph that takes into account various business semantics. These requirements are especially required when the nodes of the data flow graph contain domain specific language coding. Moreover, with domain specific language coding, the optimizer can require a parser for each domain specific language used in the data flow graph and must be aware of the semantic that is expressed with the domain specific language coding.